<template>
	<view>
		<u-empty text="还没有创作的文章" mode="list" v-if="list.length==0" style="margin-top: 400rpx;"></u-empty>
		<u-card :title="item.title" :sub-title="$u.timeFormat(item.created, 'yyyy年mm月dd日')" v-for="(item, index) in  list"
		 :key="item.id" @click="toarticle(item.id)">
			<view class="" slot="body">
				<u-image width="100%" height="300rpx" :src="item.thumbnail"></u-image>
			</view>
			<view class="" slot="foot">
				<u-icon name="list" size="34" color="" :label="'版块:'+item.categories"></u-icon>
			</view>
		</u-card>
	</view>
</template>

<script>
	import {
		mapGetters
	} from 'vuex'
	export default {
		onLoad() {
			console.log(111)
			this.$u.api.postgetListbyauthor({
				author: this.info.username
			}).then(res => {
				console.log(res)
				this.list=[]
				res.data.forEach(item=>{
					this.list.push(item)
				})
				console.log(this.list)
			})
		},
		data() {
			return {
				list:[]
			}
		},
		computed: {
			...mapGetters({
				info: "vuex_user"
			})
		},
		methods: {
			toarticle(id){
				this.$u.route('/pages/article/article', {
					id
				});
			}
		}
	}
</script>

<style>

</style>
